#!/bin/bash

attach_disk()
{
    ./virsh attach-disk --print-xml --domain testdom $@ --source /nonexistent/file
}

set -x

./virsh attach-disk
./virsh attach-disk --print-xml --domain testdom $@ --source ""
./virsh attach-disk --print-xml --domain testdom $@ --source "" --sourcetype file
./virsh attach-disk --print-xml --domain testdom $@ --source "" --sourcetype blah
attach_disk --target hda
attach_disk --target hda --sourcetype file
attach_disk --target hda --sourcetype block
attach_disk --target hda --sourcetype nothing
attach_disk --target hda --sourcetype file --type disk
attach_disk --target hda --sourcetype block --type disk
attach_disk --target hda --sourcetype file --type cdrom
attach_disk --target hda --sourcetype block --type cdrom
attach_disk --target hda --sourcetype file --type blah
attach_disk --target hda --sourcetype block --type blah
attach_disk --target hda --sourcetype file --type disk --driver testdriver
attach_disk --target hda --sourcetype file --type disk --subdriver qcow2
attach_disk --target hda --sourcetype file --type disk --subdriver raw
attach_disk --target hda --sourcetype file --type disk --cache none
attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --cache none
attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --serial TEST_SERIAL
attach_disk --target hda --sourcetype file --type disk --mode readonly
attach_disk --target hda --sourcetype file --type disk --mode shareable
attach_disk --target hda --sourcetype file --type disk --mode whatever
attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias
attach_disk --target hda --sourcetype file --type disk --rawio
attach_disk --target hda --sourcetype file --type disk --multifunction
attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --iothread 3 --mode readonly --cache none --driver qemu

attach_disk --target hda --sourcetype file --type disk --address ide:1.2.3
attach_disk --target hda --sourcetype file --type disk --address ide:1.2.4
attach_disk --target hda --sourcetype file --type disk --address ide:1:2:5
attach_disk --target sda --sourcetype file --type disk --address ide:1.2.3
attach_disk --target vda --sourcetype file --type disk --address ide:1.2.3

attach_disk --target sda --sourcetype file --type disk --address usb:12.34
attach_disk --target sda --sourcetype file --type disk --address usb:12.3
attach_disk --target sda --sourcetype file --type disk --address usb:12:34
attach_disk --target vda --sourcetype file --type disk --address usb:12.34
attach_disk --target hda --sourcetype file --type disk --address usb:12.34

attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.3
attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.4
attach_disk --target sda --sourcetype file --type disk --address scsi:1:2:5
attach_disk --target hda --sourcetype file --type disk --address scsi:1.2.3
attach_disk --target vda --sourcetype file --type disk --address scsi:1.2.3

attach_disk --target sda --sourcetype file --type disk --address sata:1.2.3
attach_disk --target sda --sourcetype file --type disk --address sata:1.2.4
attach_disk --target sda --sourcetype file --type disk --address sata:1:2:5
attach_disk --target hda --sourcetype file --type disk --address sata:1.2.3
attach_disk --target vda --sourcetype file --type disk --address sata:1.2.3

attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78
attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78
attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa
attach_disk --target hda --sourcetype file --type disk --address pci:12.34.56.aa
attach_disk --target sda --sourcetype file --type disk --address pci:12.34.56.aa

attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.78 --multifunction
attach_disk --target vda --sourcetype file --type disk --address pci:12:34:56:78 --multifunction
attach_disk --target vda --sourcetype file --type disk --address pci:12.34.56.aa --multifunction

attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56
attach_disk --target vda --sourcetype file --type disk --address ccw:12:34:56
attach_disk --target vda --sourcetype file --type disk --address ccw:12.34.56
attach_disk --target hda --sourcetype file --type disk --address ccw:12.34.56
attach_disk --target sda --sourcetype file --type disk --address ccw:12.34.56

attach_disk --target vda --sourcetype file --type disk --address test:12.34.56
attach_disk --target vda --sourcetype file --type disk --address test:12:34:56
attach_disk --target vda --sourcetype file --type disk --address test:12.34.56

./virsh attach-disk --print-xml --domain testdom $@ --source "" --source-protocol AAA
./virsh attach-disk --print-xml --domain testdom $@ --source "" --source-protocol AAA
attach_disk --target hda --source-protocol AAA --sourcetype file
attach_disk --target hda --sourcetype network
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-name hostname
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-name hostname:port
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-name hostname:
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-name :port
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-name :
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-name hostname:port --source-host-transport trnsp
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-transport trnsp
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-transport trnsp --source-host-socket /nonexistent/socket
attach_disk --target hda --sourcetype network --source-protocol TEST --source-host-socket /nonexistent/socket
